package morenoapp.util;

import java.util.List;

/**
 *
 * @author root
 */
@Deprecated
public class EnumFacade<E extends Enum> {
    Class<E> type;
    E value;
    String name;
    public EnumFacade(Class<E> type, E value) {
        this.type = type;
        this.value = value;
        this.name = I18N.get("enum." + type.getSimpleName() + "." + (value != null ? value.name() : "null"));
    }

    public E getValue() {
        return value;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EnumFacade<E> other = (EnumFacade<E>) obj;
        if (this.type != other.type && (this.type == null || !this.type.equals(other.type))) {
            return false;
        }
        if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + (this.type != null ? this.type.hashCode() : 0);
        hash = 53 * hash + (this.value != null ? this.value.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return name;
    }


    public static <T extends Enum> EnumFacade<T>[] wrapExtendedArray(Class<T> type, EnumFacade<T> first, T[] tail){
        EnumFacade<T>[] result = new EnumFacade[tail.length+1];
        result[0]=first;
        for(int i=0;i<tail.length;i++){
            result[i+1]=new EnumFacade<T>(type, tail[i]);
        }
        return result;
    }

    public static <T extends Enum> EnumFacade<T>[] wrapArray(Class<T> type, T[] tail){
        EnumFacade<T>[] result = new EnumFacade[tail.length];
        for(int i=0;i<tail.length;i++){
            result[i]=new EnumFacade<T>(type, tail[i]);
        }
        return result;
    }


    public static <T extends Enum> EnumFacade<T> createPleaseSelect(Class<T> type){
        EnumFacade<T> result = new EnumFacade<T>(type,null);
        result.name = result.name+".please_select";
        return result;
    }
//    public static <T extends Enum> EnumFacade<T> createNotSelected(Class<T> type){
//        EnumFacade<T> result = new EnumFacade<T>(type,null);
//        result.name = result.name+".not_selected";
//        return result;
//    }
}
